<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="test">闭包测试</button>

    <script>
        function outer(){
            var a = 0
            function inner(){
                a += 1
                alert('a现在是'+a)
            }
            return inner
        }

        var func1 = outer()// 闭包函数相当于自带了一个私有的全局变量，私有因为只能被闭包函数访问，全局因为具有持久性

        var test = document.getElementById('test')
        test.addEventListener('mouseup',func1)  
    </script>
</body>
</html>